"""
订单数据模型
@author:yczha
"""


from pydantic import BaseModel, validator


class OrderCreate(BaseModel):
    order_no: str
    order_name: str
    order_amount: float

    @validator('order_amount')
    def amount_should_gt_1_lt_1000(cls, v):
        if v < 1 or v > 1000:
            raise ValueError('单笔订单需要大于￥1小于￥1000')
        return str(v)
